<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
{{assign var="title" value='地址'}}
{{assign var="app" value='address'}}
{{assign var="act" value=''}}
{{assign var="td" value='6'}}
{{assign var="table" value='address'}}
<title>{{$title}}管理 - {{'admin|admin_site_name'|C|default:'后台管理'}}</title>
{{include file="include/base.html"}}
{{include file="{{$smarty.const.PLUG}}chosen/chosen.html"}}
<script>
	$(document).ready(function(){
		$offsetScrollTop = 45;
		$this_ = $('.body_right');
		$this_.scrollTop(5);
		//城市onchange
		$("form.search select[name='city']").change(function(){//select
			document.location.href="#city_"+$(this).val();
			$.post('{{"index.php?app=address&act=cityChange"|URL}}',{id:$(this).val()},function(result){
				$('select[name=area]').html(result.area);
				$('select[name=street]').html(result.street);
				$(".chosen").trigger("chosen:updated");
			},'json');
			$this_.scrollTop($this_.scrollTop()-$offsetScrollTop);
		});
		//区域onchange
		$("form.search select[name='area']").change(function(){//select
			document.location.href="#area_"+$(this).val();
			$.post('{{"index.php?app=address&act=areaChange"|URL}}',{id:$(this).val()},function(result){
				$('select[name=street]').html(result.street);
				$(".chosen").trigger("chosen:updated");
			},'json');
			$this_.scrollTop($this_.scrollTop()-$offsetScrollTop);
		});
		//街镇onchange
		$("form.search select[name='street']").change(function(){//select
			document.location.href="#street_"+$(this).val();
			$this_.scrollTop($this_.scrollTop()-$offsetScrollTop);
		});
		//是否显示
		$('.is_display').click(function(){
			if($(this).attr('checked')){
				$('.tr_'+$(this).val()).show();
			}else{
				$('.tr_'+$(this).val()).hide();
			}
			$this_.scrollTop($this_.scrollTop()-$offsetScrollTop);
		});
		//如果有锚点值:
		if(location.hash!=''){
			$this_.scrollTop($(location.hash).position().top-$offsetScrollTop*2);
		}
		//省onchange,清空其它所有选定值
		$('select[name=province]').change(function(){
			$('select[name=city] option:selected').attr('selected',false);
			$('select[name=area] option:selected').attr('selected',false);
			$('select[name=street] option:selected').attr('selected',false);
			$(".chosen").trigger("chosen:updated");
			$('form[name=search]').submit();
		});
	});
</script>
</head>
<body>

	{{include file="include/sidebar.html"}}
	
	<div class="body_right">
	<div id="content">
		<div class="search fixed_top">
		<form action="index.php?app={{$app}}" name="search" class="search router" method="get">
			<input type="hidden" name="app" value="{{$app}}"/>
			<ul class="bread">
				<li>省:</li>
				<li>
					<select name="province" class="chosen nochange">
						<option value="">选择省...</option>
						{{foreach from=$select.province item=val}}
						<option {{if $val.province_id==$smarty.request.province}}selected='selected'{{/if}} value="{{$val.province_id}}">{{$val.province_name}}</option>
						{{/foreach}}
					</select>
				</li>
				<li>城市:</li>
				<li><input class="is_display" value='city' type='checkbox' checked='checked'/></li>
				<li>
					<select name="city" class="chosen nochange">
						<option value="">选择市...</option>
						{{if $select.city AND $smarty.request.province>0}}
							{{foreach from=$select.city item=val}}
							<option {{if $val.city_id==$smarty.get.city}}selected='selected'{{/if}} value="{{$val.city_id}}">{{$val.city_name}}</option>
							{{/foreach}}
						{{/if}}
					</select>
				</li>
				<li>区域:</li>
				<li><input class="is_display" value='area' type='checkbox' checked='checked'/></li>
				<li>
					<select name="area" class="chosen nochange">
						<option value="">选择区...</option>
						{{if $select.area AND $smarty.request.province>0}}
							{{foreach from=$select.area item=val}}
							<option {{if $val.area_id==$smarty.get.area}}selected='selected'{{/if}} value="{{$val.area_id}}">{{$val.area_name}}</option>
							{{/foreach}}
						{{/if}}
					</select>
				</li>
				<li>街镇:</li>
				<li><input class="is_display" value='street' type='checkbox' checked='checked'/></li>
				<li>
					<select name="street" class="chosen nochange">
						<option value="">选择街镇...</option>
						{{if $select.street AND $smarty.request.province>0}}
							{{foreach from=$select.street item=val}}
							<option {{if $val.street_id==$smarty.get.street}}selected='selected'{{/if}} value="{{$val.street_id}}">{{$val.street_name}}</option>
							{{/foreach}}
						{{/if}}
					</select>
				</li>
				<li>
					<button type="submit" class="search btn btn-success"><i class="icon-search"></i>搜索</button>
					<a href="index.php?app=address" class="a">清除</a>
				</li>
			  </ul>
		</form>
		</div>
			
		<!--循环内容 S-->
		<form action="index.php" name="form" class="form" method="post">
		<input type="hidden" name="app" value="{{$app}}"/>
		<input type="hidden" name="act" value="save_order"/>
		<table class="table table-bordered">
		  <tbody>
			<tr class="thead">
			  <td colspan="{{$td}}"> 
			  	◆ 地址管理 -> 地址列表
			  </td>
			</tr>
			{{if !$result.province}}
			<tr class="noline"><td colspan="{{$td}}" class="result_empty"></td></tr>
			{{else}}
			<tr class="ttitle">
			  <th width="6%">ID</th>
			  <th width="">地址名称</th>
			  <th width="10%">区号</th>
			  <!-- <th width="10%">排序  <img title="保存排序" class="save_order" style="width:20px;height:20px;cursor:pointer;" src="{{$smarty.const.__APP__}}images/system/save.png"/> </th> -->
			  <th width="10%">是否发布</th>
			  <th width="200px">操作</th>
			</tr>
			{{foreach from=$result.province item=val}}
			<tr class="line">
			  {{*省ID*}}<td> {{$val.province_id}} <input type="hidden" name="id_province[]" value="{{$val.province_id}}" /></td>
			  {{*地名*}}<td align="left"><a style="font-size:14px;color:green;" href='index.php?app=address&province={{$val.province_id}}'>{{$val.province_name}}</a></td>
			  {{*区号(留空)*}}<td align="left"></td>
			  {{*排序*}}<!-- <td><input type='text' name="order_province[]" style="width:25px;" value='{{$val.ordering}}'/></td> -->
			  {{*状态*}}<td><a class="ajaxSubmit refresh" link="index.php?app=functions&act=setValue&value={{!$val.publish}}&params={{'table=address_province'|cat:'&field=publish.province_id&id='|cat:$val.province_id|encode}}"><span class="select_{{$val.publish}}">&nbsp;</span></a></td>
			  <td>
				{{*编辑*}}<a class='btn iframe' title="编辑省" width="700" height="280" href="index.php?app=address&act=modify&table=province&id={{$val.province_id}}&iframe=true"><i class="icon-edit"></i></a>
				{{*添加*}}<a class='btn iframe' title="添加市" width="700" height="280" href="index.php?app=address&act=modify&table=city&parent_id={{$val.province_id}}&iframe=true"><i class="icon-plus-sign"></i>添加市</a>
			  	{{*删除*}}<a class="btn btn-danger refresh confirm ajaxSubmit floatr" link="index.php?app={{$app}}&act=delete&type=province&id={{$val.province_id}}" title="确定要删除该省吗?"><i class="icon-trash icon-white"></i></a>
			  </td>
			</tr>
				{{if $result['city'][$val.province_id]}}
				{{foreach from=$result['city'][$val.province_id] item=v}}
					<tr class="line tr_city" id="city_{{$v.city_id}}">
					 {{*市ID*}}<td> {{$v.city_id}} <input type="hidden" name="id_city[]" value="{{$v.city_id}}" /></td>
					 {{*地名*}}<td align="left">　|----<span style="font-size:13px;color:#555;">{{$v.city_name}} {{if $v.hot_city==1}}<img src="{{$smarty.const.__APP__}}images/system/hot.gif"/> <a class="hot" href="index.php?app=address&act=set_boolean&field=hot_city&table=city&id={{$v.city_id}}&value={{$v.hot_city}}" style="color:#e78;font-size:11px;background-color:#efefef;border-radius:5px;display:none;">取消热门</a>{{else}}<a class="hot" href="index.php?app=address&act=set_boolean&field=hot_city&table=city&id={{$v.city_id}}&value={{$v.hot_city}}" style="color:#e78;font-size:11px;background-color:#efefef;border-radius:5px;display:none;">设为热门</a>{{/if}}</span></td>
					 {{*区号*}}<td align="left">{{$v.city_code}}</td>
					 {{*排序*}}<!-- <td>　<input type='text' name="order_city[]"  style="width:25px;" value='{{$v.ordering}}'/></td> -->
					 {{*状态*}}<td><a class="ajaxSubmit refresh" link="index.php?app=functions&act=setValue&value={{!$v.publish}}&params={{'table=address_city'|cat:'&field=publish.city_id&id='|cat:$v.city_id|encode}}"><span class="select_{{$v.publish}}">&nbsp;</span></a></td>
					  <td>
						{{*编辑*}}<a class='btn iframe' width="700" height="270" title="编辑市" href="index.php?app=address&act=modify&table=city&id={{$v.city_id}}&iframe=true"><i class="icon-edit"></i></a>
						{{*添加*}}<a class='btn iframe' width="700" height="270" title="添加区" href="index.php?app=address&act=modify&table=area&parent_id={{$v.city_id}}&iframe=true"><i class="icon-plus-sign"></i>添加区</a>
					  	{{*删除*}}<a class="btn btn-danger refresh confirm ajaxSubmit floatr" link="index.php?app={{$app}}&act=delete&type=city&id={{$v.city_id}}" title="确定要删除该市吗?"><i class="icon-trash icon-white"></i></a>
					  </td>
					</tr>
						{{if $result['area'][$v.city_id]}}
						{{foreach from=$result['area'][$v.city_id] item=vv}}
							<tr class="line tr_area" id="area_{{$vv.area_id}}">
							  {{*区ID*}}<td> {{$vv.area_id}} <input type="hidden" name="id_area[]" value="{{$vv.area_id}}" /></td>
							  {{*地名*}}<td align="left">　　|----<span style="font-size:12px;color:#999;">{{$vv.area_name}}</span></td>
							  {{*区号(留空)*}}<td align="left"></td>
							  {{*排序*}}<!-- <td>　　<input type='text' name="order_area[]"  style="width:25px;" value='{{$vv.ordering}}'/></td> -->
							  {{*状态*}}<td><a class="ajaxSubmit refresh" link="index.php?app=functions&act=setValue&value={{!$vv.publish}}&params={{'table=address_area'|cat:'&field=publish.area_id&id='|cat:$vv.area_id|encode}}"><span class="select_{{$vv.publish}}">&nbsp;</span></a></td>
							  <td>
								{{*编辑*}}<a class='btn iframe' width="700" height="270" title="编辑区" href="index.php?app=address&act=modify&table=area&id={{$vv.area_id}}&iframe=true"><i class="icon-edit"></i></a>
								{{*添加*}}<a class='btn iframe' width="700" height="270" title="添加街镇" href="index.php?app=address&act=modify&table=street&parent_id={{$vv.area_id}}&iframe=true"><i class="icon-plus-sign"></i>添加街镇</a>
							  	{{*删除*}}<a class="btn btn-danger refresh confirm ajaxSubmit floatr" link="index.php?app={{$app}}&act=delete&type=area&id={{$vv.area_id}}" title="确定要删除该区吗?"><i class="icon-trash icon-white"></i></a>
							  </td>
							</tr>
								{{if $result['street'][$vv.area_id]}}
								{{foreach from=$result['street'][$vv.area_id] item=vvv}}
									<tr class="line tr_street" id="street_{{$vvv.street_id}}">
									  {{*街道ID*}}<td> {{$vvv.street_id}} <input type="hidden" name="id_street[]" value="{{$vvv.street_id}}" /></td>
									  {{*地名*}}<td align="left">　　　|----<span style="font-size:11px;color:#bbb;">{{$vvv.street_name}}</span></td>
									  {{*区号(留空)*}}<td align="left"></td>
									  {{*排序*}}<!-- <td>　　　<input type='text' name="order_street[]" style="width:25px;" value='{{$vvv.ordering}}'/></td> -->
									  {{*状态*}}<td><a class="ajaxSubmit refresh" link="index.php?app=functions&act=setValue&value={{!$vvv.publish}}&params={{'table=address_street'|cat:'&field=publish.street_id&id='|cat:$vvv.street_id|encode}}"><span class="select_{{$vvv.publish}}">&nbsp;</span></a></td>
									  <td>
										{{*编辑*}}<a class='btn iframe' width="700" height="270" title="编辑街镇" href="index.php?app=address&act=modify&table=street&id={{$vvv.street_id}}&iframe=true"><i class="icon-edit"></i></a>
									  	{{*删除*}}<a class="btn btn-danger confirm refresh ajaxSubmit floatr" link="index.php?app={{$app}}&act=delete&type=street&id={{$vvv.street_id}}" title="确定要删除该街镇吗?"><i class="icon-trash icon-white"></i></a>
									  </td>
									</tr>
								{{/foreach}}
								{{/if}}
						{{/foreach}}
						{{/if}}
				{{/foreach}}
				{{/if}}
			{{/foreach}}
			{{/if}}
			<tr class="thead">
			  <td colspan="{{$td}}">
			  {{include file="include/page.html"}}
			  </td>
			</tr>
		  </tbody>
		 </table>
		</form>
		<!--循环内容 E-->
</div>
</div>
<!--固定位置浮动 S-->
<script>
$(document).ready(function(){
	var loaded = true;
	var top = $(".fixed_top").offset().top;
	var $fixedWidth = $(".fixed_top").width();
	var $fixedHeight = $(".fixed_top").height();
	function Add_Data(){

		var scrolla=$('.body_right').scrollTop()+$fixedHeight+15;
		//console.log(scrolla);
		var cha=parseInt(top)-parseInt(scrolla);
		if(loaded && cha<=0)
		{                
			$(".fixed_top").addClass("fixed");
			$('.fixed_top').width($fixedWidth);
			loaded=false;
		}
		if(!loaded && cha>0)
		{
			$(".fixed_top").removeClass("fixed");
			loaded=true;
		}
	};
	//固定滚动
	$('.body_right').scroll(Add_Data);
});
</script>
<style>
.fixed{
	position: fixed;
	top:40px;
	z-index: 9;
}
</style>
<!--固定位置浮动 E-->

</body>
</html>